package com.kokomi.direct_model;


import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class RabbitMQConfigQueue3 {
    // 1.创建一台交换机
    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange("direct_exchange");
    }
    // 2.创建两个队列
    @Bean
    public Queue directQueue1() {
        return new Queue("direct_queue1");
    }

    @Bean
    public Queue directQueue2() {
        return new Queue("direct_queue2");
    }
    // 3.将两个队列绑到交换机上
    @Bean
    public Binding directBinding1(Queue directQueue1, DirectExchange directExchange) {
        return BindingBuilder.bind(directQueue1).to(directExchange).with("gz");
    }

    @Bean
    public Binding directBinding2(Queue fanoutQueue2, DirectExchange directExchange) {
        return BindingBuilder.bind(fanoutQueue2).to(directExchange).with("sz");
    }
}
